const mysql = require('mysql')


const pool = mysql.createPool({
  host : '192.168.0.250',
  user : 'root',
  password : 'led20131111',
  database : 'dbCenter'
})



module.exports = function query( sql, values ) {
  return new Promise(( resolve, reject ) => {
    pool.getConnection(function(err, connection) {
      if (err) {
        reject( err )
      } else {
        connection.query(sql, values, ( err, rows) => {

          if ( err ) {
            reject( err )
          } else {
            resolve( rows )
          }
          connection.release()
        })
      }
    })
  })
}
